package work.jame.blog.pojo.dto;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.validation.annotation.Validated;
import work.jame.blog.framework.VerificationGroup;
import work.jame.blog.pojo.User;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;

/**
 * 用户登录封装类
 *
 * @author : Jame
 * @date : 2023-05-10 16:20
 **/
@ApiModel(description = "用户包装类")
public class UserDTO {

    /**
     * 当用户5分钟内3次账号或密码错误后需要传图形验证码
     * 图形验证码
     */
    @ApiModelProperty("验证码")
    private String code;

    /**
     * 邮箱验证码
     */
    @ApiModelProperty("邮箱验证码")
    private String emailCode;

    /**
     * 当修改密码操作时传入旧密码
     */
    @ApiModelProperty("旧密码")
    private String oldPassword;

    /**
     * user对象
     */
    @NotNull(message = "用户数据不能为空",
            groups = {
                    VerificationGroup.Save.class,
                    VerificationGroup.Login.class,
                    VerificationGroup.Update.class
            }
    )
    @Valid //嵌套检查
    private User user;

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public String getOldPassword() {
        return oldPassword;
    }

    public void setOldPassword(String oldPassword) {
        this.oldPassword = oldPassword;
    }

    public String getEmailCode() {
        return emailCode;
    }

    public void setEmailCode(String emailCode) {
        this.emailCode = emailCode;
    }

    @Override
    public String toString() {
        return "UserDTO{" +
                "code='" + code + '\'' +
                ", oldPassword='" + oldPassword + '\'' +
                ", user=" + user +
                '}';
    }
}
